/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.blog.city.checkthedep.sessionbeans;

import com.blog.city.checkthedep.entities.Tag;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Breath
 */
@Stateless
public class TagFacade extends AbstractFacade<Tag> implements TagFacadeLocal {
    @PersistenceContext(unitName = "com.blog.city_CheckTheDep_war_1.0-SNAPSHOTPU")
    private EntityManager em;

    /**
     * 
     * @return
     */
    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
    
    /**
     * 
     * @param em
     */
    protected void setEm(EntityManager em) {
        this.em = em;
    }

    /**
     * 
     */
    public TagFacade() {
        super(Tag.class);
    }
    
    /**
     * 
     * @param name
     * @return
     */
    @Override
    public Tag findTagByName(String name){
         return (Tag) this.getEntityManager().createQuery("SELECT c FROM Tag c WHERE c.name = :name").setParameter("name", name).getSingleResult();
    }
    
}
